package com.example.demopage.controller;

import com.example.demopage.bean.User;
import com.example.demopage.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.UUID;

@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping(value = "/addUser.do")
    public Object addUser() {
        try {
            User user = new User();
            user.setId(String.valueOf(UUID.randomUUID()));
            user.setName("William Smith");
            user.setAge(28);
            user.setBirthday(new Date());
            userMapper.insertUser(user);
            return user;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
